package com.xinyan.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.xinyan.pojo.SprayAdCategory;
import com.xinyan.mapper.SprayAdCategoryMapper;
import com.xinyan.service.ISprayAdCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xzlf
 * @since 2024-03-19 17:57:43
 */
@Service
public class SprayAdCategoryServiceImpl  implements ISprayAdCategoryService {

    @Autowired
    private SprayAdCategoryMapper sprayAdCategoryMapper;

    @Override
    public PageDTO<SprayAdCategory> findByPage(long page, long size) {
        PageDTO<SprayAdCategory> pageDTO = sprayAdCategoryMapper.selectPage(new PageDTO<SprayAdCategory>(page, size), null);
        return pageDTO;
    }


    @Override
    public void updateById(SprayAdCategory adCategory) {
        sprayAdCategoryMapper.updateById(adCategory);
    }

    @Override
    public void addAdCategory(SprayAdCategory adCategory) {
        sprayAdCategoryMapper.insert(adCategory);
    }

    @Override
    public void deleteAdCategory(int id) {
        SprayAdCategory category = sprayAdCategoryMapper.selectById(id);
        category.setStatus(3);
        sprayAdCategoryMapper.updateById(category);
    }
}
